﻿using System.Windows;
using Microsoft.Phone.Controls;

namespace VisualStudioAchievements
{
    public static class HtmlStringLoader
    {
        public static readonly DependencyProperty HtmlStringProperty = DependencyProperty.RegisterAttached("HtmlString",
            typeof(string), typeof(HtmlStringLoader), new PropertyMetadata(HtmlStringChanged));

        private static void HtmlStringChanged(DependencyObject dObject, DependencyPropertyChangedEventArgs e)
        {
            if (dObject != null)
            {
                WebBrowser browser = dObject as WebBrowser;
                browser.NavigateToString(e.NewValue as string);
            }
        }

        public static string GetHtmlString(WebBrowser dObject)
        {
            if (dObject != null)
            {
                return (string)dObject.GetValue(HtmlStringProperty);
            }
            else
                return "TEST";
        }

 
        public static void SetHtmlString(WebBrowser dObject, string value)
        {
            if (dObject != null)
            {
                dObject.SetValue(HtmlStringProperty, value);
            }
        }
    }
}
